import { useIntersectionObserver } from "@vueuse/core";
export const vLazyLoad = (app) => {
  app.directive("lazy-load", {
    async mounted(el, binding) {
      let def = await import("@/assets/images/ai.png");
      el.src = def.default;
      let { stop } = useIntersectionObserver(el, ([{ isIntersecting }]) => {
        if (isIntersecting) {
          el.src = binding.value;
          stop();
        }
      });
    },
    async updated(el, binding) {
      let def = await import("@/assets/images/ai.png");
      el.src = def.default;
      let { stop } = useIntersectionObserver(el, ([{ isIntersecting }]) => {
        if (isIntersecting) {
          el.src = binding.value;
          stop();
        }
      });
    },
  });
};
